package com.rd.student.jiaji.class3.xumingze;

import java.util.LinkedList;

public class Student
{
    public int age;
    private int id;
    public String name;
    public String cls;
    public String major;
    public String desc;
    public String codeNum;
    public Student(){

    }
    public Student(String name, String Cls, String major, int age,String desc,String codeNum)
    {
        this.name = name;
        this.cls = cls;
        this.major = major;
        this.age = age;
        this.desc = desc;
        this.codeNum = codeNum;
    }
    //根据年龄范围返回
    public static LinkedList ageRange(LinkedList list, int a, int b){
        LinkedList list1=new LinkedList<>();
        for (int i = 0; i < list.size(); i++) {
            Student s=(Student) list.get(i);
            if (s.getAge()>a&&s.getAge()<=b)
                list1.add(list.get(i));
        }
        return list1;
    }

    public static LinkedList NameUtils(LinkedList l){
        LinkedList list1=new LinkedList();
        for (int i=0;i<l.size();i++){
            Student s=(Student) l.get(i);
            list1.add(s.getName());
        }
        return list1;
    }
    public static LinkedList AgeUtils(LinkedList list) {
        int ave = 0;
        Student s;
        LinkedList dowm = new LinkedList();
        for (int i = 0; i < list.size(); i++) {
            s = (Student) list.get(i);
            ave += s.age;

        }
        System.out.println("小组成员的平均年龄为：" + ave / list.size());
        return list;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", cls='" + cls + '\'' +
                ", major='" + major + '\'' +
                ", age=" + age +
                ", desc='" + desc + '\'' +
                ", codeNum='" + codeNum + '\'' +
                '}' + "\n";
    }


    public String getName() {
        return name;
    }

    public String getCls() {
        return cls;
    }

    public String getMajor() {
        return major;
    }

    public int getAge() {
        return age;
    }

    public String getDesc() {
        return desc;
    }

    public String getCodeNum() {
        return codeNum;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setCls(String cls) {
        this.cls = cls;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setCodeNum(String codeNum) {
        this.codeNum = codeNum;
    }

}
